package com.ydgk.ajax;

import com.alibaba.fastjson.JSON;
import com.ydgk.dao.TeacherDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet(name = "TeacherDeleteAjaxServlet", urlPatterns = "/TeacherDeleteAjaxServlet.action")
public class TeacherDeleteAjaxServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tid = request.getParameter("tid");
        TeacherDao teacherDao = new TeacherDao();
        int i = teacherDao.deleteById(Integer.parseInt(tid));
        Map map = new HashMap();
        if(i>0){
            map.put("flag",true);
        }else {
            map.put("flag",false);
        }
        response.getWriter().print(JSON.toJSONString(map));
    }


}
